﻿using System.Collections.Generic;
using System.Linq;

namespace Fabrication.ValueProviders
{
    internal abstract class RandomStringProvider : ValueProviderBase<string>
    {
        private readonly IEnumerable<string> strings;

        protected RandomStringProvider(IEnumerable<string> strings)
        {
            this.strings = strings;
        }

        protected override string GetValue(object item)
        {
            var maxIndex = strings.Count() - 1;
            return strings.ElementAt(RandomNumberGenerator.GetInteger(0, maxIndex));
        }
    }
}